package com.bdqn.service.impl;

import com.bdqn.mapper.HisPatientMapper;
import com.bdqn.pojo.HisPatient;
import com.bdqn.service.HisPatientService;
import lombok.Data;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.text.SimpleDateFormat;
import java.util.Date;

@Service
public class HisPatientServiceImpl implements HisPatientService {
    @Autowired
    HisPatientMapper hisPatientMapper;

    @Override
    public HisPatient getHisPatientDANGE(String idCard) {
        long currentTimeMillis = System.currentTimeMillis();
        SimpleDateFormat formatter = new SimpleDateFormat("yyyy");
        Date date = new Date(currentTimeMillis);
        HisPatient hisPatient=hisPatientMapper.getHisPatientDANGE(idCard);
//        birthday
        if (hisPatient!=null){
            hisPatient.setNianling(formatter.format(date));
            hisPatient.setNianlingyh(hisPatient.getBirthday().substring(0,4));
        }
        return hisPatient;
    }

    @Override
    public int addHisPatient(HisPatient hisPatient) {
        return hisPatientMapper.addHisPatient(hisPatient);
    }
}
